<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
body{font-size:12px;}
h1{font-weight:bold;font-size:12px;}
</style>
<script type="text/javascript" src="__ROOT__/Public/Js/jquery-1.5.0.min.js"></script>
<script type="text/javascript" src="__ROOT__/Public/Js/core.js"></script>
<script type="text/javascript" src="__TMPL__js/jquery.dragndrop.js"></script>	
<script type="text/javascript" src="__TMPL__js/jquery.msgbox.js"></script>
<script>
	 //x,0=未登录，1=成功，2=失败,3=请求已发送，4=黑名单，5=已是好友
	function wClose(t){
	   if(t!='0'){
	     //t=pars
	     top.$mb.setAnimation(t)
            .setAutoClose(t);
		}else{
		  top.$mb.close();
		}
	  }
	function addTeam(){
	  //alert('il');
	  $('#new_team').html('<input name="name" id="name" type="text" size="10" maxlength="10" /><input name="" type="button" onclick="formSubmit(2)" value="添加" />');//css('display','block');
	} 
	
	function formSubmit(t){
	  $('#type').val(t);
	  var name=$('#name').val();
	  // var content=$('#content').val();
	  if(t==2 && name!=''){
	   ajax.sendForm('addForm',
	    function(data){
          if(data.result=='1'){
		     $("#ftid").get(0).options.add(new Option(name,data.key));
			 $("#ftid ").get(0).value=data.key;
		  }	 	
		}
	    );
	  }else if(t==1){
	    ajax.sendForm('addForm',
	    function(data){
          switch(data.result){
		    case 0:{alert('您还没有登录，请登录后再试');wClose(2);};break;
			case 1:{alert('成功发送请求');wClose(2);};break;
			case 3:{alert('您已发送过请教，正等待对方回应');wClose(2);};break;
			case 5:{alert('该用户已经您你的好友了');wClose(2);};break;
			default:{};break;
		  }		  	 	
		}
	    );
	  }else{
	    return false;
	  }
	}  
	
   

	</script>
<title>添加好友</title>
</head>

<body style="width:420px;height:200px;overflow:hidden;">
  <if condition="$status eq 'ok'">
   <form id="addForm" name="form1" method="post" action="__URL__/addFriendAjaxSubmit">
     <table width="398" border="0" align="center">
       <tr>
         <td colspan="2"><h1>您确定要添加"{$member.username}"为好友吗？<h1></td>
       </tr>
       <tr>
         <td width="124" rowspan="2" valign="middle" align="center"><img src="{$member.icon}" width="100" height="100" /></td>
         <td width="264" align="left">发送请求信息<br />
             <label>
             <input name="content" type="text" id="content" size="20" maxlength="50" />
             </label>
         </td>
       </tr>
       <tr>
         <td height="24" align="left"><label>
           <select name="ftid" id="ftid">
             <option value="0">默认分组</option>
             <volist name='teams' id='item'>
               <option value="{$item.ftid}">{$item.name}</option>
             </volist>
           </select>
           </label>
           &nbsp;&nbsp;<a href="#" onclick="return addTeam()">增加分组</a><br />
		   <span id="new_team" ></span>
		   </td>
       </tr>
       <tr>
         <td>&nbsp;</td>
         <td align="left"><label>
		   <input name="type" id="type" type="hidden" value="1" />
		   <input name="friendid"  type="hidden" value="{$friendid}" />
           <input type="button" name="button" onclick="formSubmit(1)" value="提交" />
           </label>
           &nbsp;&nbsp;&nbsp;
           <input name="Input" type="reset" onclick="return wClose(0);" value="取消" /></td>
       </tr>
     </table>
   </form>
   </if>
   
   <if condition="$status eq 'not_login'">
       <div style="width:200px;height:200px;overflow:hidden;margin:10px auto;color:#33CCFF">您还没有登录，请登录再试</div>
	   <script>wClose(2);</script>
   </if>
   
   <if condition="$status eq 'param_error'">
      <div style="width:200px;height:200px;overflow:hidden;margin:10px auto;color:#33CCFF">参数错误，稍候返回</div>
	   <script>wClose(2);</script>
   </if>
   
   <if condition="$status eq 'add_myself'">
      <div style="width:200px;height:200px;overflow:hidden;margin:10px auto;color:#33CCFF">无法添加自己为好友，稍候返回</div>
	   <script>wClose(2);</script>
   </if>
</body>
</html>
